package com.huawei.hianalytics.ab.bc.kl;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build.VERSION;
import android.text.TextUtils;
import com.huawei.hianalytics.ab.bc.ij.ab;
import java.io.File;

public class bc {
    public static boolean ab(Context context) {
        return System.currentTimeMillis() - ab.bc(context, "Privacy_MY", "flashKeyTime", -1) > 43200000;
    }

    public static boolean ab(Context context, String str) {
        if (context == null) {
            return true;
        }
        if (VERSION.SDK_INT < 23) {
            if (context.getPackageManager().checkPermission(str, context.getPackageName()) != 0) {
                com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "not have read phone permission!");
                return true;
            }
        } else if (context.checkSelfPermission(str) != 0) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "not have read phone permission!");
            return true;
        }
        return false;
    }

    @SuppressLint({"DefaultLocale"})
    public static boolean ab(Context context, String str, int i) {
        if (new File(context.getFilesDir(), "../shared_prefs/" + (ab.ab(context, str) + ".xml")).length() <= ((long) i)) {
            return false;
        }
        com.huawei.hianalytics.ab.bc.ef.ab.bc("hmsSdk", String.format("reach local file limited size - file len: %d limitedSize: %d", new Object[]{Long.valueOf(new File(context.getFilesDir(), "../shared_prefs/" + (ab.ab(context, str) + ".xml")).length()), Integer.valueOf(i)}));
        return true;
    }

    public static boolean ab(String str, long j, long j2) {
        if (TextUtils.isEmpty(str)) {
            return true;
        }
        try {
            return j - Long.parseLong(str) > j2;
        } catch (NumberFormatException e) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("TaskAssistant", "isTimeExpired(): Data type conversion error : number format !");
            return true;
        }
    }
}
